(function ($) {  
	Drupal.behaviors.cust_avatar = {    
		attach: function(context, settings) {
			var slideX = {
			      thisUl: $('.catalog ul.imgbox'),
			      btnLeft: $('.leftclick'),
			      btnRight: $('.rightclick'),
			      thisLi: $('.catalog ul.imgbox li'),
			      init: function () {
			          slideX.thisUl.width(slideX.thisLi.length * 113);
			          //slideX.slideAuto();
			          slideX.btnLeft.click(slideX.slideLeft).hover(slideX.slideStop, slideX.slideAuto);
			          slideX.btnRight.click(slideX.slideRight).hover(slideX.slideStop, slideX.slideAuto);
			          slideX.thisUl.hover(slideX.slideStop, slideX.slideAuto);
			      },
			      slideLeft: function () {
			          slideX.btnLeft.unbind('click', slideX.slideLeft);
			          slideX.thisUl.find('li:last').prependTo(slideX.thisUl);
			          slideX.thisUl.css('marginLeft', -113);
			          slideX.thisUl.animate({ 'marginLeft': 0 }, 350, function () {
			              slideX.btnLeft.bind('click', slideX.slideLeft);
			          });
			          return false;
			      },
			      slideRight: function () {
			          slideX.btnRight.unbind('click', slideX.slideRight);
			          slideX.thisUl.animate({ 'marginLeft': -113 }, 350, function () {
			              slideX.thisUl.css('marginLeft', '0');
			              slideX.thisUl.find('li:first').appendTo(slideX.thisUl);
			              slideX.btnRight.bind('click', slideX.slideRight);
			          });
			          return false;
			      },
			      slideAuto: function () {
			          //slideX.intervalId = window.setInterval(slideX.slideRight, 3000);
			      },
			      slideStop: function () {
			          //window.clearInterval(slideX.intervalId);
			      }
			  }
			  $(document).ready(function () {
			      slideX.init();
			  })  
		}
	};
})(jQuery);